<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />

		<script src="../../js/lib/code-mirror-v5.33.0/lib/codemirror.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/lib/code-mirror-v5.33.0/mode/javascript/javascript.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../js/lib/code-mirror-v5.33.0/lib/codemirror.css" />

		<title>Document</title>
	</head>

	<body>
		<h2>code mirror editor</h2>
		<textarea id="editor">there is some text... <br/> some text...</textarea>
		<script type="text/javascript">
			var editor = document.querySelector('#editor');
//			var codeEditor1 = CodeMirror(function(elt) {
//				editor.parentNode.replaceChild(elt, editor);
//			}, {
//				value: editor.value,
//				lineNumbers: true,
//				mode: 'javascript'
//			});
			//两者等价
			var codeEditor2 = CodeMirror.fromTextArea(editor, {
				value: editor.value,
				lineNumbers: true,
				mode: 'javascript'
			})
		</script>
	</body>

</html>